#!/bin/bash

# 设置您的项目文件夹路径
projects_folder="/Users/jiangan/IdeaProjects/"

# 获取项目文件夹中的所有子文件夹（假设每个子文件夹是一个Git项目）
project_folders=$(find "$projects_folder" -maxdepth 1 -mindepth 1 -type d)

# 定义要跳过的文件夹名称
skip_folders=("chickenWar" "dingdong-helper" "luce" "lucene" "Selected-Works-of-Mao-Zedong-JingHuo-version" "springboot_demo")

# 遍历每个项目文件夹
for project_folder in $project_folders; do
    # 获取项目文件夹名称
    folder_name=$(basename "$project_folder")
    
    # 检查是否要跳过该文件夹
    if [[ " ${skip_folders[@]} " =~ " $folder_name " ]]; then
        echo "Skipping $folder_name"
        continue
    fi
    
    # 打印文件夹名称日志
    echo "Entering folder: $folder_name"
    
    # 进入项目文件夹
    cd "$project_folder" || continue
    
    # 切换到master分支
    git checkout master
    
    # 拉取最新代码
    git pull
    
    # 返回到原始目录
    cd -
done
